/**
 * @author
 * Simple Servlet example
 */
package nl.soekoor;

import java.io.IOException;
import java.io.PrintWriter;
import java.util.Calendar;

import javax.servlet.Servlet;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

/**
 * Servlet implementation class for Servlet: SimpleServlet.
 *
 */
public class SimpleServlet extends HttpServlet implements Servlet {

/**
* serialVersionUID.
*
*/
private static final long serialVersionUID = 1L;

/**
* Constructor.
*
*/
public SimpleServlet() {
super();
}

/**
 * @author
 * @param request
 * @param response
 * @throws IOException 
 * @throws IOException
 * @throws ServletException
 */
protected final void doGet(HttpServletRequest request, HttpServletResponse response) throws IOException {
performTask(response);


}

/**
 * @author .
 * @param: request.
 * @param: response.
 * @throws IOException.
 * @throws ServletException.
 */
protected final void doPost(HttpServletRequest request, HttpServletResponse response)throws ServletException, IOException {
doGet(request, response);
}


/**
 * @author .
 * @param response
 * @throws IOException
 */
public final void performTask(HttpServletResponse response) {
PrintWriter out;
String title = "Test Soekoor";
try {
out = response.getWriter();
out.println("<HTML><HEAD><TITLE>");
out.println(title);
out.println("</TITLE></HEAD><BODY>");
out.println("<H1>" + title + "</H1>");
out.println("<P>This is output from Soekoor SimpleServlet.");
out.println("<P>Today is: " + getDateInfo());
out.println("</BODY></HTML>");
out.close();
} catch (IOException e) {
e.printStackTrace();
}

}

/**
 * @author .
 * @return dayOfWeek
 *
 */
public final String getDateInfo() {
String dayOfWeek = "";
Calendar calendar = Calendar.getInstance();
int day = calendar.get(Calendar.DAY_OF_WEEK);
switch(day) {
case Calendar.SUNDAY: dayOfWeek = "Sunday"; break;
case Calendar.MONDAY: dayOfWeek = "Monday"; break;
case Calendar.TUESDAY: dayOfWeek = "Tuesday"; break;
case Calendar.WEDNESDAY: dayOfWeek = "Wednesday"; break;
case Calendar.THURSDAY: dayOfWeek = "Thursday"; break;
case Calendar.FRIDAY: dayOfWeek = "Friday"; break;
case Calendar.SATURDAY: dayOfWeek = "Saturday"; break;
default: dayOfWeek = "Invalid day"; break;
}
return dayOfWeek;
}
}

